const devConfig = {
  httpProtocol: 'http://',
  wsProtocol: 'ws://',
  // host: 'mos-test.hc-iiot.com',
  host: 'mos-dev.hc-iiot.com',
  // host: '172.28.101.53',
  // port: '8080',
  prefix: '/api/',
  wsPath: '/ws'
}

// const testConfig = {
//   httpProtocol: 'http://',
//   wsProtocol: 'ws://',
//   host: '172.28.101.107', // 集成测试
//   port: '9090',
//   // host: '172.28.101.173',
//   // port: '8080',
//   prefix: '/api/',
//   wsPath: ''
// }

const prodConfig = {
  httpProtocol: window.location.protocol + '//',
  wsProtocol: (window.location.protocol === 'https:' ? 'wss:' : 'ws:') + '//',
  host: window.location.hostname,
  port: window.location.port,
  prefix: '/api/',
  wsPath: '/ws'
}

const apiConfig = process.env.NODE_ENV === 'production' ? prodConfig : devConfig

export default apiConfig

const { httpProtocol, host, port, prefix } = apiConfig
export const rootURL = `${httpProtocol}${host}${port ? ':' + port : ''}`
export const baseURL = `${rootURL}${prefix}`
